{{extend '../_layouts/home.html'}} {{block 'head'}}
<style>
    html {
        height: 100%;
    }
    
    body {
        display: flex;
        flex-direction: column;
        min-height: 100%;
    }
    
    header {
        height: 50px;
    }
    
    .navbar {
        display: flex;
        flex-flow: row wrap;
        justify-content: space-between;
        align-items: center;
        width: 80%;
        margin: 0 auto;
        height: 50px;
    }
    
    .navbar-left {
        display: flex;
        flex-flow: row wrap;
        justify-content: space-between;
        align-items: center;
    }
    
    .search {
        border-radius: 20px;
        border: none;
        outline: none;
        background-color: #888;
        padding-left: 15px;
        transition: all .3s;
    }
    
    .navbar-right ul:nth-child(1) li {
        /* float: left; */
        display: inline-block;
        list-style: none;
    }
    
    .navbar-list a {
        padding: 10px 15px;
        color: #ccc;
        font-size: 14px;
    }
    
    .navbar-right a:hover {
        text-decoration: none;
        color: #fff;
    }
    
    .logo {
        width: 120px;
        height: 28px;
        margin: 0 10px;
    }
    
    form {
        display: inline-block;
    }
    
    .btn {
        margin-right: 10px;
        padding: 5px 20px;
        border-radius: 3px;
    }
    
    footer {
        height: 100px;
        padding: 30px 0 0 30px;
        margin: 15px 0 0 0;
        background-color: #fff;
        color: #666;
    }
    
    main {
        flex: 1;
        padding: 15px 0 0 0;
    }
    
    .main {
        max-width: 1400px;
        background-color: #fff;
        margin-right: 305px;
        border-radius: 3px;
    }
    /* .container {
            max-width: 1400px;
        } */
    
    aside {
        float: right;
        width: 290px;
        height: 400px;
        font-size: 14px;
    }
    
    aside::after {
        content: '';
        display: block;
        clear: both;
    }
    
    aside div:nth-child(2) {
        height: auto;
        text-align: center;
        padding: 20px 0;
    }
    
    .panel {
        background-color: #fff;
        margin-bottom: 15px;
        height: 200px;
        width: 100%;
    }
    
    .cell {
        width: 100%;
        padding: 15px;
        border-bottom: 1px solid #f0f0f0;
    }
    
    .userInfo {
        position: relative;
        display: flex;
        flex-flow: row wrap;
        align-items: center;
        padding: 0 !important;
        color: #fff !important;
    }
    
    .avatar {
        width: 28px;
        height: 24px;
    }
    
    .icon-xiala {
        height: 12px;
        width: 15px;
    }
    
    .userCount {
        display: none;
        position: absolute;
        width: 120px;
        background-color: #fff;
        text-align: left;
        padding-left: 0;
    }
    
    .userCount li {
        display: block !important;
        text-align: left;
        padding-left: 10px;
    }
    
    .userCount a {
        color: #000;
    }
    
    .userCount a:hover {
        color: #007bff;
    }
    
    .userNickname {
        color: #3498db;
    }
</style>
{{/block}} {{block 'body'}}

<main>
    <div class="container">
        <form action="" id="publish_form">
            <div>
                <label for="">请输入标题</label>
                <input type="text" name="title">
            </div>
            <div>
                <label for="">请输入内容</label>
                <textarea name="message" id="" cols="30" rows="10"></textarea>
            </div>
            <button type="submit" class="btn btn-primary">提交</button>
        </form>
    </div>
</main>

{{/block}} {{block 'script'}}
<script>
    $(function() {



        $('#publish_form').on('submit', function(e) {
            e.preventDefault()
            let formData = $(this).serialize()

            $.ajax({
                type: 'POST',
                url: '/publish',
                data: formData,
                dataType: 'json',
                success: function(data) {
                    var err_code = data.err_code
                    if(err_code === 0){
                        window.alert('发表评论成功')
                        window.location.href='/'
                    }
                }
            })
        })
    })
</script>
{{/block}}